<template>
  <div class="pane-phone">
    <el-form label-position="right" label-width="80px" :rules="rules" :model="formData" ref="formRef">
      <el-form-item label="手机号" prop="phone">
        <el-input v-model="formData.phone" />
      </el-form-item>
      <el-form-item label="验证码" prop="code">
        <div class="code-verify">
          <el-input v-model="formData.code" />
          <el-button type="primary" @click="() => { }" class="code-btn">获取验证码</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import type { FormRules } from 'element-plus';
import { reactive } from 'vue';
interface IPhone {
  phone: string,
  code: string
}

const formData = reactive({
  phone: '',
  code: ''
})

const rules: FormRules<IPhone> = {
  phone: [
    { required: true, message: '请输入手机号', trigger: 'blur' },
    { pattern: /^1[0-9]{10}$/, message: '必须是11位数字组成', trigger: 'blur' }
  ],
  code: [
    { required: true, message: '请输入验证码' },
    { len: 6, message: '请输入6位数验证码' }
  ]
}

</script>
<style scoped lang="less">
.pane-phone {
  .code-verify {
    display: flex;

    .code-btn {
      margin-left: 10px;
    }
  }
}
</style>
